# -*- coding: utf-8 -*-
# author : hxt
#   date : 2025/2/20

'''
文件名必需这个，不能改
'''

import logging
import pytest
# from extend.keywords import KeyWords
#
# keywords = KeyWords()

@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):
    out = yield
    res = out.get_result()
    if res.when == "call":
        logging.info(f"用例ID：{res.nodeid}")
        logging.info(f"测试结果：{res.outcome}")
        logging.info(f"故障表示：{res.longrepr}")
        logging.info(f"异常：{call.excinfo}")
        logging.info(f"用例耗时：{res.duration}")
        logging.info("**************************************")

# @pytest.fixture(scope='session')
# def token_fix():
#     # 1、登录
#     with allure.step('进行登录操作'):
#         url = "http://shop-xo.hctestedu.com/index.php?s=api/user/login"
#         data = {
#             "accounts": "xxtest",
#             "pwd": "111111",
#             "type": "username"
#         }
#
#         params = {
#             "application": "app",
#             "application_client_type": "weixin",
#         }
#         res = keywords.request_post(url=url, params=params, json=data)
#         # 获取响应数据msg
#         msg_res = jsonpath.jsonpath(res.json(), '$..msg')[0]
#         # 断言
#         assert msg_res == '登录成功', f'当前msg的信息是：{msg_res}'
#         print('用户登录成功')
#         # 获取token
#         token = jsonpath.jsonpath(res.json(), '$..token')[0]
#         # print(r1.json())
#         print('当前登录token : ', token)
#         return token